#ifndef _MATERIALFILTER_H_
#define _MATERIALFILTER_H_

#include <optional>
#include <unordered_map>
#include <SERender/Resourses/Material.h>

namespace SEngine
{

    class MaterialFilter
    {
    public:
        MaterialFilter() = default;
        virtual ~MaterialFilter() = default;

        void AddMaterial(const std::string & name, ResRef<Material> material) { m_materials.emplace(name, std::move(material)); }
        std::optional<ResRef<Material>> GetMaterial(const std::string & name) {
            if (m_materials.find(name) == m_materials.end())
                return std::nullopt;
            else 
                return m_materials.at(name);
        }
        void Foreach(std::function<void(std::string, ResRef<Material>&)> && fn) { for (auto & [name, material] : m_materials) { fn(name, material); } }
    private:
        std::unordered_map<std::string, ResRef<Material>> m_materials;
    };
} // namespace SEngine


#endif